package com.phone.client.controller;

import com.seventh.common.pojo.R;
import com.phone.client.poji.entry.TbCoupon;
import com.phone.client.poji.vo.CoupVo;
import com.phone.client.service.CoupService;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @program: clms-seventh
 * @description: 优惠券的控制层
 * @author: 杨佳琪
 * @create: 2021-07-24 16:03
 **/
@RestController
@RequestMapping("client/coup")
@Api(tags="优惠券控制层")
public class CouponController {
    @Resource
    private CoupService coupService;

    @ApiOperation("分页查询")
    @PostMapping("initCoupTable/{currentPage}/{pageSize}")
    public R initCoupTable(@ApiParam(value = "页码",name = "currentPage") @PathVariable("currentPage") Integer currentPage,@ApiParam(value = "条数",name = "pageSize") @PathVariable("pageSize") Integer pageSize,
                             @RequestBody CoupVo coupVo){
        return coupService.initCoupTable(currentPage,pageSize,coupVo);
    }

    @ApiOperation("删除")
    @DeleteMapping("deleteCoup/{id}")
    public R deleteCoup(@PathVariable Integer id){
        return coupService.deleteCoup(id);
    }

    @ApiOperation("修改")
    @PutMapping("updateCoup")
    public R updateCoup(@RequestBody TbCoupon tbCoupon){
        return coupService.updateCoup(tbCoupon);
    }

    @ApiOperation("新增")
    @PostMapping("insertCoup")
    public R insertCoup(@RequestBody TbCoupon tbCoupon){
        return coupService.insertCoup(tbCoupon);
    }

    @ApiOperation("修改的回显")
    @GetMapping("findCoupById/{id}")
    public R findCoupById(@PathVariable Integer id){
        return coupService.findCoupById(id);
    }

    @PostMapping("selCode")
    @ApiOperation("查询优惠码是否唯一")
    public R selPhone(@ApiParam("优惠券信息")@RequestBody TbCoupon tbCoupon){
        return coupService.selCode(tbCoupon);
    }
}
